package org.cloudnote.controller;


import lombok.extern.slf4j.Slf4j;
import org.cloudnote.bean.User;
import org.cloudnote.service.UserService;
import org.cloudnote.bean.NoteResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RequestMapping("/user")
@RestController
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/login.do")
    public NoteResult login(String username, String password, HttpServletRequest request){
//        System.out.println(1/0);
        NoteResult result = userService.login(username, password);
       return result;
   }
   @RequestMapping("/register.do")
    public NoteResult register(User user){
       NoteResult result = userService.register(user);
       return result;
   }

}
